<?php

/*
 CI Library Keys
 Written by: Ciprian Dimofte - 01-18-2010
 */

class Keys{
    public $CI;
    public $consumer_key;
    public $secret_key;
    public $timestamp;
    
    public function __construct(){
        $this->CI =& get_instance();
        
        $this->CI->load->library("settings");
        
        $this->consumer_key = $this->CI->settings->get_param("consumer_key");
        $this->secret_key   = $this->CI->settings->get_param("secret_key");
        if(!$this->timestamp){
            $this->timestamp    = time();
        }
        
        
    }
    
    public function public_key($other_fields = array()){
        ksort($other_fields);
        $public_key = hash_hmac("sha256", 
                                      $this->consumer_key.$this->timestamp . "-" . implode("||||", $other_fields), 
                                      $this->secret_key
                                     );
       return $public_key;
    }
    
     
}

?>